package com.itfreer.gis.data.server;

import org.locationtech.jts.geom.Geometry;
import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType;

import java.util.List;

/**
 * 定义数据服务，实现对数据的新增，编辑，删除操作
 */
public interface DataEditServer {

	/**
	 * 查询
	 * @param source
	 * @param where 			查询的依据
	 * @return
	 */
	List<SimpleFeature> queryFeature(String source, String where) throws Exception;

	/**
	 * 查询
	 * @param source
	 * @param option 	查询的操作(相交:INTERSECT，包含:CONTAINS等)
	 * @param geometry 	查询空间条件
	 * CQL.toFilter( "CONTAINS(ATTR1, POINT(1 2))" );
	 * CQL.toFilter( "BBOX(ATTR1, 10,20,30,40)" );
	 * CQL.toFilter( "DWITHIN(ATTR1, POINT(1 2), 10, kilometers)" );
	 * CQL.toFilter( "CROSS(ATTR1, LINESTRING(1 2, 10 15))" );
	 * CQL.toFilter( "INTERSECT(ATTR1, GEOMETRYCOLLECTION (POINT (10 10),POINT (30 30),LINESTRING (15 15, 20 20)) )" );
	 * CQL.toFilter( "CROSSES(ATTR1, LINESTRING(1 2, 10 15))" );
	 * CQL.toFilter( "INTERSECTS(ATTR1, GEOMETRYCOLLECTION (POINT (10 10),POINT (30 30),LINESTRING (15 15, 20 20)) )" );
	 * @return
	 */
	List<SimpleFeature> queryFeature(String source, String option, Geometry geometry) throws Exception;

	/**
	 * 新增
	 *
	 * @return
	 */
	Boolean addFeatures(String source, List<SimpleFeature> datas, SimpleFeatureType metadata) throws Exception;

	/**
	 * 编辑
	 *
	 * @return
	 */
	SimpleFeature updateFeature(String source, SimpleFeature row, SimpleFeatureType metadata) throws Exception;

	/**
	 * 删除
	 *
	 * @return
	 */
	Boolean deleteFeature(String source, String where) throws Exception;

	/**
	 * 获取数据源数据
	 * @param tableName
	 * @return
	 */
	SimpleFeatureType getTableMetadata(String tableName);
}
